#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QComboBox>
#include <QLineEdit>
#include <QSpinBox>
#include <QTextBrowser>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QTcpSocket>
#include <QList>
#include <QNetworkInterface>

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

private:
    //设置界面
    void setupUi();
    void getLocalHostIP();
    void connectSigsToSlots();

private slots:
    void toConnect();
    void toDisConnect();
    void connected();
    void disConnected();
    void clearTextBrowser();
    void receiveMessage();
    void sendMessage();
    void socketStateChanged(QAbstractSocket::SocketState state);

private:
    QTcpSocket* tcpSocket;
    QList<QHostAddress> list;
    QPushButton* button[4];
    QLabel* label[2];
    QLineEdit* lineEdit;
    QComboBox* comboBox;
    QSpinBox* spinBox;
    QTextBrowser* browser;
    QHBoxLayout* hLayout[3];
    QVBoxLayout* vLayout;
};
#endif // WIDGET_H
